<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>商家扫二维码消费</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <!--<link rel="stylesheet" type="text/css" href="../css/style.css"/>-->
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css"/>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css"/>
    <style>
        body {
            background: transparent;
            font-size: 14px;
            overflow: auto;

        }

        .font-24 {
            font-size: 24px;
        }

        .aui-btn {
            height: 55px;
            line-height: 55px;
        }
    </style>
</head>

<body>
<div class="contain ">
    <div class="aui-mask"></div>
    <div class="z-index99-positon aui-flex-col aui-text-center " style="line-height: 52px;">
        <div class="aui-flex-item-6 aui-text-left"><i
                class="aui-iconfont aui-padded-10  aui-icon-left colorWhite font-24" tapmode
                onclick="closeScanner()"></i></div>
        <!--<div class="aui-flex-item-4"><i class="aui-iconfont aui-padded-10 aui-icon-picfill colorWhite font-24" tapmode-->
        <!--onclick="openPic()"></i></div>-->
        <div class="aui-flex-item-6 divLight aui-text-right"><i
                class="aui-iconfont  aui-padded-10 aui-icon-light colorWhite font-24" tapmode
                onclick="openLight(this)" status="off"></i></div>


    </div>
    <footer class="aui-nav z-index99 height-auto " style="background-color: transparent;" tapmode
            onclick="openToTwo('')">
        <div class="  aui-padded-0 codeInputDiv dispalyNone-unImportant   noBorder radius-0 " tapmode onclick="entryCode()">
            <input type="number" class="aui-margin-0 codeInput" placeholder="输入二维码下方的编号" /></div>
        <div class="aui-btn aui-block aui-padded-0 aui-bg-primary colorWhite noBorder radius-0 " >输入编号
        </div>

    </footer>
</div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript">
    var goodId, companyName, money, orderId, orderNo, count = 1;
    var vmoney = "", type = "", FNScanner = "";
    apiready = function () {

        var height = $api.offset($api.dom('body')).h;
        var width = $api.offset($api.dom('body')).w;
        var scanner_width = width - 120;
        FNScanner = api.require('FNScanner');
        FNScanner.openView({
            autorotation: false,
            rect: {
                x: 60,   //（可选项）数字类型；模块左上角的 x 坐标（相对于所属的 Window 或 Frame）；默认：0
                y: 80,   //（可选项）数字类型；模块左上角的 y 坐标（相对于所属的 Window 或 Frame）；默认：0
                w: scanner_width, //（可选项）数字类型；模块的宽度；默认：所属的 Window 或 Frame 的宽度
                h: scanner_width * height / width  //（可选项）数字类型；模块的高度；默认：所属的 Window 或 Frame 的高度
            }
        }, function (ret, err) {
            if (ret) {
                if (ret.eventType == 'success') {

                    var code = ret.content;
//                    alert(url)
                    useCode(code)
                    //注册
//                    var code = getUrlParam(url, "code");
                }
            } else {
                api.toast({
                    msg: "扫码失败，请重试"
                })
            }
        });
    }

    function closeScanner() {
        FNScanner.closeView();
        closeFrame();
    }
    function openLight(obj) {
        var status = $(obj).attr("status") == "on" ? "off" : "on";
        if ($(obj).attr("status") == "on") {
            $(obj).attr("status", "off")
        } else {
            $(obj).attr("status", "on")
        }
        FNScanner.switchLight({
            status: status
        });
    }
    function openPic() {
        FNScanner.decodeImg({
            path: ''
        }, function (ret, err) {
            if (ret.status) {
                alert(JSON.stringify(ret));
            } else {
                alert(JSON.stringify(err));
            }
        });
    }
    //消码
    function useCode(code) {
        var url = "order/supplier_checkcode";
        var data = {};
        data["code"] = code
        getStorageAll();
        ajaxRequest(url, 'post', data, function (ret, err) {
            api.toast({
                msg: "消费成功！",
                location: "middle"
            })

        })
        closeScanner();
    }
    $(function () {
        $(".aui-btn").unbind("click").bind("click",entryCode)
    })
    function entryCode() {
        FNScanner.closeView();
        $(".divLight").hide();
        $(".codeInputDiv").show();
        $(".aui-btn").text("确定消费");
        $(".aui-btn").unbind("click").bind("click",entryMakeSure)

    }
    function entryMakeSure() {
        var code=$(".codeInput").val();
        if(code!=""){
            useCode(code);
        }else{
            api.toast({
                msg:"消费编码不能为空"
            });
        }
    }
</script>

</html>
